package br.com.alinesoftware.app.entity;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import com.powerlogic.jcompany.config.domain.PlcReference;
import com.powerlogic.jcompany.domain.validation.PlcUnifiedValidation;
import java.util.List;
import javax.persistence.OneToMany;
import javax.persistence.CascadeType;
import javax.persistence.FetchType;
import org.hibernate.annotations.ForeignKey;

@MappedSuperclass
@PlcUnifiedValidation
public abstract class ControleAcesso implements Serializable {

	private static final long serialVersionUID = 4746786546846487372L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "SE_CONTROLE_ACESSO")
	@Column(nullable = false, length = 5)
	private Long id;

	@OneToMany (targetEntity = br.com.alinesoftware.app.entity.GrupoAcessoControleEntity.class, fetch = FetchType.LAZY, cascade=CascadeType.ALL, mappedBy="controleAcesso")
	@ForeignKey(name="FK_GPOACESCONT_CONTACES")
	private List<GrupoAcessoControle> grupoAcessoControle;

	@NotNull
	@Size(max = 32)
	@Column
	@PlcReference(testDuplicity = true)
	private String login;

	@NotNull
	@Size(max = 32)
	@Column
	private String senha;

	// TODO - Descomentar @NotNull
	@Column
	private Boolean senhaValidada;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getLogin() {
		return login;
	}

	public void setLogin(String login) {
		this.login = login;
	}

	public String getSenha() {
		return senha;
	}

	public void setSenha(String senha) {
		this.senha = senha;
	}

	public Boolean getSenhaValidada() {
		return senhaValidada;
	}

	public void setSenhaValidada(Boolean senhaValidada) {
		this.senhaValidada = senhaValidada;
	}

	public List<GrupoAcessoControle> getGrupoAcessoControle() {
		return grupoAcessoControle;
	}

	public void setGrupoAcessoControle(List<GrupoAcessoControle> grupoAcessoControle) {
		this.grupoAcessoControle=grupoAcessoControle;
	}

}
